﻿<?php
require_once 'jsmin.php';
require_once 'class.JavaScriptPacker.php';
require_once 'http.php';

set_time_limit(0);

$p_output = '../../../../../bin/html5as3multiupload';

$s_list = array(
	//"swfobject.js",
	"multiUpload_src.js",
	"html5as3multiupload_src.js"
);

$result = '';

foreach ($s_list as $path)
{
	$filepath = $path;
	$content = file_get_contents($filepath);
	$result .= "\r\n\r\n".$content;
}

$pubDate = "/* HTML5AS3MultiUp v0.1 ("
		.date_format( new DateTime(), 'ymd-i' )
		.") <http://code.google.com/p/html5-as3-multiupload/>\n"
		."	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */\r\n";
$swfobj = file_get_contents("swfobject.js");
		
function _w($w_path, $w_cont){
	global $pubDate;
	global $swfobj;
	
	$w_cont = $swfobj
		."\r\n\r\n"
		.$pubDate
		.$w_cont;
	
	$out = fopen($w_path . '.js', "w");
	fwrite($out, $w_cont);
	fclose($out);
}

//_w($p_output, $result);

$result = JSMin::minify($result);
_w($p_output, $result);

$packer = new JavaScriptPacker($result, 62, true, false);
$result = $packer->pack();
_w($p_output.'_pack', $result);


echo 'finished at '.time();
?>